<?php

namespace App\Admin\Actions\Post;

use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;

class AuditOk extends RowAction
{
    public $name = '审核通过';

    public function handle(Model $model)
    {
        if( $model->merchant_status != 1 ){
            $model->merchant_status = 1;
            $model->save();
            \DB::table('subsidy')->where('uid', $model->id)->where('status', 0)->update(['status'=>1, 'updated_at'=>getDt()]);
            \DB::table('stores')->where('uid', $model->id)->where('status', 0)->update(['status'=>1, 'updated_at'=>getDt()]);
        }

        return $this->response()->success('审核通过')->refresh();
    }

}